<!DOCTYPE html >
<html>
<head>
<meta name="Generator" content="tpshop" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>修改地址-{$tpshop_config['shop_info_store_title']}</title>
<meta http-equiv="keywords" content="{$tpshop_config['shop_info_store_keyword']}" />
<meta name="description" content="{$tpshop_config['shop_info_store_desc']}" />
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<link rel="stylesheet" href="__STATIC__/css/public.css">
<link rel="stylesheet" href="__STATIC__/css/user.css">

<script src="__PUBLIC__/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="__STATIC__/js/layer.js" ></script>
<script src="__PUBLIC__/js/global.js"></script>
<script src="__PUBLIC__/js/mobile_common.js"></script>
<link rel="stylesheet" href="__STATIC__/css/font-awesome.min.css">
<link rel="stylesheet" href="__STATIC__/css/icomoon.css">
</head>
<body>
<div class="tab_nav tab_nav_none">
    <div class="header">
	<a href="javascript:void(0);" onClick="javascript:history.go(-1);" class="header_l"><i class="fa fa-angle-left"></i></a>
      <div class="h-mid">地址管理   </div>
	<a href="{:U('Index/index')}" class="header_r"><i class="fa fa-home"></i></a>
	  
    </div>
</div>
       	 <include file="Public/menu"/>
<div id="tbh5v0">
						
<div class="addressmone">
  <form action="{:U('Mobile/User/edit_address')}" method="post" onSubmit="return checkForm()">
	<ul>
       <li>
    	<span>收貨人姓名</span>  
        <input name="consignee" id="consignee" type="text" value="{$address.consignee}" maxlength="12" placeholder="收貨人姓名"/>
		</li>          
       <li>
          <span>地區</span>  
          <input name='country' value='1' type="hidden">
	             <select class="province_select"  name="province" id="province" onChange="get_city(this)">
                      <option value="0">請選擇</option>
                        <volist name="province" id="p">
                            <option <if condition="$address['province'] eq $p['id']">selected</if>  value="{$p.id}">{$p.name}</option>
                        </volist>
                 </select>
                <select name="city" id="city" onChange="get_area(this)">
                    <option  value="0">請選擇</option>
                    <volist name="city" id="p">
                        <option <if condition="$address['city'] eq $p['id']">selected</if>  value="{$p.id}">{$p.name}</option>
                    </volist>
                </select>
                <select name="district" id="district" onChange="get_twon(this)">
                    <option  value="0">請選擇</option>
                    <volist name="district" id="p">
                        <option <if condition="$address['district'] eq $p['id']">selected</if>  value="{$p.id}">{$p.name}</option>
                    </volist>
                </select>                 
                <select class="di-bl fl seauii" name="twon" id="twon" <if condition="$address['twon'] gt 0 ">style="display:block;"<else/>style="display:none;"</if>>
                    <volist name="twon" id="p">
                        <option <if condition="$address['twon'] eq $p['id']">selected</if>  value="{$p.id}">{$p.name}</option>
                    </volist>
                </select>          
        	</li>
           <li>
    		 <span>詳細地址</span> <input type="text"  name="address" id="address" placeholder="詳細地址" maxlength="100" value="{$address.address}"/>
	       </li>
           <li>
			<span>手機</span> 
            <input type="text" name="mobile" value="{$address.mobile}" onpaste="this.value=this.value.replace(/[^\d-]/g,'')" onKeyUp="this.value=this.value.replace(/[^\d-]/g,'')" maxlength="15" placeholder="手機號碼"/>
	        </li>
            <li>
	    		<span>郵政編碼</span> 
                <input type="text" name="zipcode" value="{$address.zipcode}" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onKeyUp="this.value=this.value.replace(/[^\d]/g,'')" maxlength="10"  placeholder="郵政編碼"/>
	        </li>
    	</ul>
            <div style=" height:50px"></div>
				<div class="dotm_btn">
                
                <if condition="$_GET['source'] eq 'cart2'"> <!--如果是下訂單時提交過了的頁面-->
                     <input type="submit" value="保存並使用該地址" class="dotm_btn1" />
	                 <input type="hidden" name="source" value="{$_GET[source]}" />
                <else/>                
                     <a href="javascript:void(0);" onClick="if (confirm('妳確認要刪除該收貨地址嗎？'))location.href='{:U('/Mobile/User/del_address',array('id'=>$address[address_id]))}'" class="dotm_btn2" style="color:#666;">刪除</a>
                     <a href="{:U('/Mobile/User/set_default',array('id'=>$address[address_id]))}" class="dotm_btn3" style=" color:#FFF;font-size:14px;">設置為默認地址</a>
                     <input type="submit" value="保存" class="dotm_btn1" />
                </if>
                 
                </div>
                <input type="hidden" name="id" value="{$address.address_id}" />
		 
    </form>
</div>        </div>
<include file="Public/footer_nav"/>
<script src="__PUBLIC__/js/validate2.js"></script>
<script>
    function checkForm(){
        var consignee = $('input[name="consignee"]').val();
        var province = $('select[name="province"]').find('option:selected').val();
        var city = $('select[name="city"]').find('option:selected').val();
        var district = $('select[name="district"]').find('option:selected').val();
        var address = $('input[name="address"]').val();
        var mobile = $('input[name="mobile"]').val();
        var error = '';
        if(consignee == ''){
            error += '收貨人不能為空 <br/>';
        }
        if(province==0){
            error += '請選擇省份 <br/>';
        }
        if(city==0){
            error += '請選擇城市 <br/>';
        }
        if(district==0){
            error += '請選擇區域 <br/>';
        }
        if(address == ''){
            error += '請填寫地址 <br/>';
        }
        if(!checkMobile(mobile)){
            error += '手機號碼格式有誤 <br/>';
		}
        if(error){
		    layer.open({content:error,time:2});
            return false;
        }
			 
        return true;
    }
</script> 
</body>
</html>